package com.eascs.admin.o2o.loan.trans;

import com.eascs.admin.o2o.loan.entity.LoanApplyFileEntity;
import com.eascs.admin.o2o.loan.entity.O2oLoanUserEntity;
import com.eascs.admin.o2o.loan.entity.O2oLoanUserEntityExp;
import com.eascs.crm.common.custnew.entity.CustomerEntity;
/**
 * 实体转vo
 * @author xingwang
 *
 */
import com.eascs.crm.common.entity.CustomerBasicInfoEntity;
public class O2oLoanUserTransFormart {
	/**
	 * CustomerBasicInfoEntity转换O2oLoanUserEntity
	 * @param o2oLoanUserEntity
	 * @param actionForm
	 * @return
	 */
	public static O2oLoanUserEntity customerToloanUser(O2oLoanUserEntity o2oLoanUserEntity, CustomerEntity customer, String loanApplyNo) {
		o2oLoanUserEntity.setCustomerName(customer.getCustomerName());
//		o2oLoanUserEntity.setCustomerType(customer.getCustomerType());
		o2oLoanUserEntity.setDocumentNo(customer.getIdNumber());
		o2oLoanUserEntity.setDocumentType(customer.getIdType());
		o2oLoanUserEntity.setSex(customer.getSex());
		o2oLoanUserEntity.setLoanId(customer.getCustomerId());
		o2oLoanUserEntity.setUserFullName(customer.getCustomerName());
		o2oLoanUserEntity.setUserName(customer.getCustomerGivenName());
		o2oLoanUserEntity.setUserNamePinyin(customer.getCustomerNamePinyin());
		o2oLoanUserEntity.setUserPhone(customer.getMobileNumber());
		o2oLoanUserEntity.setUserSurName(customer.getCustomerFamilyName());
		o2oLoanUserEntity.setSurnamePinyin(customer.getCustomerFamilyNamePy());
		o2oLoanUserEntity.setNamePinyin(customer.getCustomerGivenNamePy());
		o2oLoanUserEntity.setLoanappNo(loanApplyNo);
		return o2oLoanUserEntity;
	}
	
	/**
	 * CustomerBasicInfoEntity转换O2oLoanUserEntity
	 * @param o2oLoanUserEntity
	 * @param actionForm
	 * @return
	 */
	public static O2oLoanUserEntity customerNewToloanUser(O2oLoanUserEntity o2oLoanUserEntity, CustomerEntity customer, String loanApplyNo) {
		o2oLoanUserEntity.setCustomerName(customer.getCustomerName());
		//o2oLoanUserEntity.setCustomerType(customer.getCustomerType());
		o2oLoanUserEntity.setDocumentNo(customer.getIdNumber());
		o2oLoanUserEntity.setDocumentType(customer.getIdType());
		o2oLoanUserEntity.setSex(customer.getSex());
		o2oLoanUserEntity.setLoanId(customer.getCustomerId());
		o2oLoanUserEntity.setUserFullName(customer.getCustomerName());
		o2oLoanUserEntity.setUserName(customer.getCustomerGivenName());
		o2oLoanUserEntity.setUserNamePinyin(customer.getCustomerNamePinyin());
		o2oLoanUserEntity.setUserPhone(customer.getMobileNumber());
		o2oLoanUserEntity.setUserSurName(customer.getCustomerFamilyName());
		o2oLoanUserEntity.setLoanappNo(loanApplyNo);
		o2oLoanUserEntity.setSurnamePinyin(customer.getCustomerFamilyNamePy());
		o2oLoanUserEntity.setNamePinyin(customer.getCustomerGivenNamePy());
		O2oLoanUserEntityExp o2oLoanUserEntityExp = new O2oLoanUserEntityExp();
		if(customer.getMaritalStatus()!=null){
			o2oLoanUserEntityExp.setMaritalStatus(customer.getMaritalStatus());
		}
		if(customer.getLicenseExpirationDate()!=null){
			o2oLoanUserEntityExp.setLicenseExpirationDate(customer.getLicenseExpirationDate());
		}
		o2oLoanUserEntity.setO2oLoanUserEntityExp(o2oLoanUserEntityExp);
		return o2oLoanUserEntity;
	}
	
	/**
	 * @description actionForm  transformation o2oLoanUserEntity
	 * @param o2oLoanUserEntity
	 * @param actionForm
	 * @return
	 */
	public static O2oLoanUserEntity trans(O2oLoanUserEntity o2oLoanUserEntity, LoanApplyFileEntity actionForm) {
		o2oLoanUserEntity.setCustomerName(actionForm.getCustomerName());
		o2oLoanUserEntity.setCustomerType(actionForm.getCustomerType());
		o2oLoanUserEntity.setDocumentNo(actionForm.getDocumentNo());
		o2oLoanUserEntity.setDocumentType(actionForm.getDocumentType());
		o2oLoanUserEntity.setSex(actionForm.getSex());
		o2oLoanUserEntity.setUserFullName(actionForm.getUserFullName());
		o2oLoanUserEntity.setUserName(actionForm.getUserName());
		o2oLoanUserEntity.setUserNamePinyin(actionForm.getUserNamePinyin());
		o2oLoanUserEntity.setUserPhone(actionForm.getUserPhone());
		o2oLoanUserEntity.setUserSurName(actionForm.getUserSurName());

		return o2oLoanUserEntity;
	}
	
	/**
	 * @description actionForm  transformation o2oLoanUserEntity of Spouse
	 * @param o2oLoanUserEntity
	 * @param actionForm
	 * @return
	 */
	public static O2oLoanUserEntity transSpouse(O2oLoanUserEntity o2oLoanUserEntity, LoanApplyFileEntity actionForm){
		o2oLoanUserEntity.setUserFullName(actionForm.getUserFullNameSpouse());
		o2oLoanUserEntity.setUserPhone(actionForm.getUserPhoneSpouse());
		o2oLoanUserEntity.setCustomerName(actionForm.getCustomerNameSpouse());
		o2oLoanUserEntity.setCustomerType(actionForm.getCustomerTypeSpouse());
		o2oLoanUserEntity.setDocumentNo(actionForm.getDocumentNoSpouse());
		o2oLoanUserEntity.setDocumentType(actionForm.getDocumentTypeSpouse());
		return o2oLoanUserEntity;
	}
	
	/**
	 * @description actionForm  transformation customerBasicInfoEntity
	 * @param customerBasicInfoEntity
	 * @param actionForm
	 * @return
	 */
	public static CustomerBasicInfoEntity transCustomerEntity(CustomerBasicInfoEntity customerBasicInfoEntity,LoanApplyFileEntity actionForm){
		customerBasicInfoEntity.setCustomerName(actionForm.getUserFullName());
		customerBasicInfoEntity.setCustomerNamePinyin(actionForm.getUserNamePinyin());
		customerBasicInfoEntity.setCustomerFamilyName(actionForm.getUserSurName());
		customerBasicInfoEntity.setCustomerGivenName(actionForm.getUserName());
		customerBasicInfoEntity.setSex(actionForm.getSex());
		customerBasicInfoEntity.setCustomerType(actionForm.getCustomerType());
		customerBasicInfoEntity.setMobileNumber(actionForm.getUserPhone());
		customerBasicInfoEntity.setIdType(actionForm.getDocumentType());
		customerBasicInfoEntity.setIdNumber(actionForm.getDocumentNo());
		return customerBasicInfoEntity;
	}
	
	/**
	 * @description actionForm  transformation customerBasicInfoEntity Spouse
	 * @param customerBasicInfoEntity
	 * @param actionForm
	 * @return
	 */
	public static CustomerBasicInfoEntity transCustomerSpouseEntity(CustomerBasicInfoEntity customerBasicInfoEntity,LoanApplyFileEntity actionForm){
		customerBasicInfoEntity.setCustomerName(actionForm.getUserFullNameSpouse());
		customerBasicInfoEntity.setMobileNumber(actionForm.getUserPhoneSpouse());
		customerBasicInfoEntity.setIdNumber(actionForm.getDocumentNoSpouse());
		customerBasicInfoEntity.setIdType(actionForm.getDocumentTypeSpouse());
		customerBasicInfoEntity.setCustomerType(actionForm.getCustomerTypeSpouse());
		return customerBasicInfoEntity;
	}
}
